#include "translate.h"


translate::translate()
{
	loadDic();
	loadText();
}


translate::~translate()
{
}

void translate::loadDic()
{
	ifstream in("translation.txt");
	string line;
	while (getline(in, line))
	{
		istringstream iss(line);
		string word, translation;
		getline(iss, word, ';');
		getline(iss, translation);
		dic.emplace(word, translation);
	}
	in.close();
}

void translate::loadText()
{
	ifstream in("story.txt");
	ostringstream s;
	s << in.rdbuf();
	text = s.str();
}

void translate::printOrig()
{
	cout << text << endl;
}

void translate::printTrans()
{
	istringstream iss(text);
	ostringstream oss;
	string word;
	while (iss >> word)
	{
		oss << dic[word] << " ";
	}
	string t = oss.str();
	cout << t << endl;

}